#!/usr/bin/python  
import sys  
import json
import datetime



FIELD_SPLIT='\t'
CLECTION_SPLIT='\002'
MAP_SPLIT='\003'


while 1:
	try:
		line=sys.stdin.readline()
		if(not line):
			break

		line=line.strip ("#|~")  

		listls=line.split("#|~")

		#print len(listls)

		if(len(listls)<9):
			continue

		#print str(listls[0]).index(" ") 	

		
		logtime=listls[0]  
		times=listls[1]
		uid =listls[2]
		guid=listls[3] 
		platform=listls[4] 
		appname=listls[6] 
		route=listls[5] 
		apicontent=listls[7] 
		context=listls[8] 	
		othertimes=listls[9]
		#apicontent=apicontent.replace('\\','')
		#context=context.replace('\\','')

		css=json.loads(apicontent)

		if(css.has_key('conditions')):
			conditions=css['conditions']
			del(css["conditions"])
		else : 
			conditions={}

		if(css.has_key('result_list')):	
			resultList=css['result_list']
			del(css["result_list"])
		else :
			#print line
			resultList={}

		if(css.has_key('request_id')):		
			requestId=css['request_id']
			del(css["request_id"])
		else : 
			requestId=''
		if(css.has_key('strategy')):	
			strategy=css['strategy']
			del(css["strategy"])
		else:
			strategy=''
		
		
		newcs=''
		for k, v in css.iteritems():
		     newcs+= str(k) +MAP_SPLIT+ str(v)
		     newcs+= CLECTION_SPLIT
		newcs=newcs[0:len(newcs)-1]

		newcons =''
		for k, v in conditions.iteritems():
		     newcons+= str(k) +MAP_SPLIT+ str(v)
		     newcons+= CLECTION_SPLIT
		newcons=newcons[0:len(newcons)-1]

		newrList =''
		for k in resultList:
		     newrList+= str(k) +CLECTION_SPLIT
		newrList=newrList[0:len(newrList)-1]

		#othertimes=othertimes[0:len(othertimes)-1]
		print FIELD_SPLIT.join([uid , guid , times , platform ,appname ,route ,newrList , newcs ,newcons ,context ,requestId,strategy ,logtime,othertimes])  
	except Exception, e:
		errormsg="runtime except"+str(e) 
		#print line 
		#print "runtime except"+str(e) 

